package com.controller;


import com.entity.UserMetadata;
import com.util.CookieUtil;
import com.util.LocalInformation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping(value = "/user_data_part")
public class UserDataController {

    @RequestMapping(value = "/user_data_show")
    public ModelAndView user_data_show(HttpServletRequest request){
        ModelAndView modelAndView = new ModelAndView();

        String user_cookie_value = CookieUtil.getUserCookie(request).getValue();  //cookie
        if(user_cookie_value != null && UserMetadata.OnlineUserId.containsKey(user_cookie_value)) {

            modelAndView.addObject("id",LocalInformation.getTimeID());
            modelAndView.setViewName("User-data-manager");
        } else {
            modelAndView.setViewName("login");
        }

        return modelAndView;
    }
}
